[sqlalchemy] Re: column_prefix with synonym

2007-06-29 Thread svilen

 if youre trying to lock down __dict__ and all that with magic, i
 think you need to instead get better users :).  its python, its
 unrealistic to try to make a java-sandboxlike application that cant
 be messed with.
stop with this java labeling. think wider. java is just some (poor) 
language that does not allow dynamic properties.
For certain usages static properties are good. For some - extremely 
good (protocols). For other usages they are bad, and just out of 
question. 

Language and its characterisitcs (dynamic/static typing, 
dynamic/static containnment, declaration vs definition, scopes, 
visibility, callability, expressions, etc) are just tools. So instead 
of using 20 poorly combinable/tweakable readymade languages, i 
simulate - or express their semantics - all of them within python, 
within same application or even library. Python allows me to do that 
(eh, some magic IS required). And when i neet yet another semantix 
(e.g. makefile-like functionalism, or .ini file configs, or 
report-description language, whatever), i just go ahead and express 
it in python syntax, sometimes replaceing the whole semantix 
underneath, e.g. what class namespace is. Thus i save on readability, 
the parser is ready, the result is python-objects which are diredctly 
application usable, etc.

As of the users - this is called defensive programing. somewhat Like 
defensive driving. The user might be me, 1 month later, using adress 
instead of address and losing 2 hours to find out why that stupid 
thing broke.

ciao
svil

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column_prefix with synonym

2007-06-28 Thread jdu

Thanks for the quick fixe.
Couldn't this read only class property also be set on any mapped
attribute so that I can remove the boilerplate Synonym and just use
the original mapped attribute as a read only one? A mapper level
readonly option (like column_prefix) would be very useful too.

On 27 juin, 22:47, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jun 27, 2007, at 3:48 PM, jdu wrote:





  It seems that both options don't work in common:

  dates = Table('dates', meta,
  Column('date', Date, primary_key=True)
  )
  mapper(MyDate, dates, column_prefix='_', properties=dict(
  date = synonym('_date'),
  )

  produces with 0.3.8:

  ArgumentError: WARNING: column 'date' not being added due to property
  'sqlalchemy.orm.interfaces.SynonymProperty object at 0x8ec91ac'.
  Specify 'allow_column_override=True' to mapper() to ignore this
  condition.

 this is a bug, fixed in r2795.



  I don't want override. My underlying goal is to make MyDate readOnly.
  As mapped attributes are already properties, it would be great to be
  able to
  'declare' the readonly behaviour in the mapper.

 id say this is out of scope for mapper.  id favor adding a property
 argument to SynonymProperty that specifies a property class (i.e.
 __get__(), __set__(), __delete__()) to be assembled on the class
 (currently the proxy=True argument will assemble a default accessor
 to the column-mapped attribute).


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column_prefix with synonym

2007-06-28 Thread svilen

  I don't want override. My underlying goal is to make MyDate
  readOnly. As mapped attributes are already properties, it would
  be great to be able to
  'declare' the readonly behaviour in the mapper.

 id say this is out of scope for mapper.  id favor adding a
 property argument to SynonymProperty that specifies a property
 class (i.e. __get__(), __set__(), __delete__()) to be assembled on
 the class (currently the proxy=True argument will assemble a
 default accessor to the column-mapped attribute).

i have some opinion/wishes around this one too.
i have a complete validating/verificating descriptors for all my 
attributes (plus no other attributes are allowed on my model-related 
classes - my static_type framework). Those includes 
type/value-validation, autoconvert, readonly etc etc metainfo. SA 
does overwrite them all with InstrumentedAttributes which basicly 
allow any values to go in.
curently i'm workarounding most if this by hacking the __dict__ 
descriptor, postfactum, but it does not work 100% (and is slow). 
Sooner or later i'll have to hack the InstrumentedAttrs myself, to 
accomodate/add the behaviour i need.

can we think of some way to nicely replace/overload/tune those 
InstrumentedAttrs - and any other SA-enforced 
descriptors/properties/methods on user's class (e.g.__init__()) - 
into something enhanceable/tweakable by user?
This may not be an immediate goal, maybe 0.5 or similar..

ciao

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column_prefix with synonym

2007-06-28 Thread Michael Bayer


On Jun 28, 2007, at 4:12 AM, svilen wrote:
 i have some opinion/wishes around this one too.
 i have a complete validating/verificating descriptors for all my
 attributes (plus no other attributes are allowed on my model-related
 classes - my static_type framework). Those includes
 type/value-validation, autoconvert, readonly etc etc metainfo. SA
 does overwrite them all with InstrumentedAttributes which basicly
 allow any values to go in.
 curently i'm workarounding most if this by hacking the __dict__
 descriptor, postfactum, but it does not work 100% (and is slow).
 Sooner or later i'll have to hack the InstrumentedAttrs myself, to
 accomodate/add the behaviour i need.

 can we think of some way to nicely replace/overload/tune those
 InstrumentedAttrs - and any other SA-enforced
 descriptors/properties/methods on user's class (e.g.__init__()) -
 into something enhanceable/tweakable by user?
 This may not be an immediate goal, maybe 0.5 or similar..


use the column_prefix option so that youre  InstrumentedAttributes  
get moved away into their own distinctly-named attributes.  then  
define your own properties to do anything you want.  its in the  
docs.  you can easily make your own mapper() function that does  
whatever you want in this regard automatically.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column_prefix with synonym

2007-06-28 Thread sdobrev

On Thursday 28 June 2007 17:50:17 Michael Bayer wrote:
 On Jun 28, 2007, at 4:12 AM, svilen wrote:
  i have some opinion/wishes around this one too.
  i have a complete validating/verificating descriptors for all my
  attributes (plus no other attributes are allowed on my
  model-related classes - my static_type framework). Those includes
  type/value-validation, autoconvert, readonly etc etc metainfo. SA
  does overwrite them all with InstrumentedAttributes which basicly
  allow any values to go in.
  curently i'm workarounding most if this by hacking the __dict__
  descriptor, postfactum, but it does not work 100% (and is slow).
  Sooner or later i'll have to hack the InstrumentedAttrs myself,
  to accomodate/add the behaviour i need.
 
  can we think of some way to nicely replace/overload/tune those
  InstrumentedAttrs - and any other SA-enforced
  descriptors/properties/methods on user's class (e.g.__init__()) -
  into something enhanceable/tweakable by user?
  This may not be an immediate goal, maybe 0.5 or similar..

 use the column_prefix option so that youre  InstrumentedAttributes
 get moved away into their own distinctly-named attributes.  then
 define your own properties to do anything you want.  its in the
 docs.  you can easily make your own mapper() function that does
 whatever you want in this regard automatically.
yes, this is one way to go.
But it will still allow access via the hidden SA props, when anyone 
finds about them, plus the __dict__ is also there. As people always 
find a reason to avoid validators (i wanna break free! off 
framework), it will surely happen. Src code police? urgh. 
i may put some simple trigger in the svn not to allow commiting files 
containing __dict__[] or x._sa_hidden_propr = ... but that gets 
smelly.

When/if i hack the InstrAttr __get__/_set__,_delete__, i'll tell u 
what/how i did it. i guess some inheritance would be enough.

later
svil

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column_prefix with synonym

2007-06-27 Thread Michael Bayer


On Jun 27, 2007, at 3:48 PM, jdu wrote:


 It seems that both options don't work in common:

 dates = Table('dates', meta,
 Column('date', Date, primary_key=True)
 )
 mapper(MyDate, dates, column_prefix='_', properties=dict(
 date = synonym('_date'),
 )

 produces with 0.3.8:

 ArgumentError: WARNING: column 'date' not being added due to property
 'sqlalchemy.orm.interfaces.SynonymProperty object at 0x8ec91ac'.
 Specify 'allow_column_override=True' to mapper() to ignore this
 condition.

this is a bug, fixed in r2795.


 I don't want override. My underlying goal is to make MyDate readOnly.
 As mapped attributes are already properties, it would be great to be
 able to
 'declare' the readonly behaviour in the mapper.

id say this is out of scope for mapper.  id favor adding a property  
argument to SynonymProperty that specifies a property class (i.e.  
__get__(), __set__(), __delete__()) to be assembled on the class  
(currently the proxy=True argument will assemble a default accessor  
to the column-mapped attribute).




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column_prefix()

2006-12-19 Thread Michael Bayer

yeah the prop on your c instance is going to be called _name in
this case.  use the synonym() function to put name back on your
mapper as a property.

http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_properties_overriding


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---