declarative

Other ways besides databindng to assign a value to a property declaratively

You can assign values to properties that are strings, numbers, etc. like this <asp:Control property="stringvalue" /> However when the property type is something complex(a class type) you must do this: <asp:Control property=<%#Value%> /> And then call the data binding command to set the value. In some scenarios calling the databind...

SQLAlchemy custom query column

I have a declarative table defined like this: class Transaction(Base): __tablename__ = "transactions" id = Column(Integer, primary_key=True) account_id = Column(Integer) transfer_account_id = Column(Integer) amount = Column(Numeric(12, 2)) ... The query should be: SELECT id, (CASE WHEN transfer_account_id=1 T...

custom *arbitrary* TemplateField definitions

I'm building a GridView on the fly, and I'd like to pre-define the TemplateFields to be included ondemand. So, what I'd like to do is have a declarative file that defines how the different templates look for a specific column. Like: <asp:TemplateField> <HeaderTemplate> this is a text column </HeaderTemplate...

Generic Data Structure Description Language

I am wondering whether there exists any declarative language for arbitrarily describing the format and semantics of a data structure, that can be compiled to a specific implementation of that structure in any of a set of target languages. That is, something like a generic data definition language but geared toward describing arbitrary da...

sqlalchemy relation through another (declarative)

Is anyone familiar with ActiveRecord's "has_many :through" relations for models? I'm not really a Rails guy, but that's basically what I'm trying to do. As a contrived example consider Projects, Programmers, and Assignments: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy import Column, Fo...

SQLAlchemy: a better way for update with declarative?

I am a SQLAlchemy noob. Let's say I have an user table in declarative mode: class User(Base): __tablename__ = 'user' id = Column(u'id', Integer(), primary_key=True) name = Column(u'name', String(50)) When I know user's id without object loaded into session, I update such user like this: ex = update(User.__table__).where(...

Dynamic Class Creation in SQLAlchemy

We have a need to create SQLAlchemy classes to access multiple external data sources that will increase in number over time. We use the declarative base for our core ORM models and I know we can manually specify new ORM classes using the autoload=True to auto generate the mapping. The problem is that we need to be able generate them dy...

How to set an asp:listitem to an enumeration value declaratively?

I have an asp:RadioButtonList and want to declaratively bind the value to an enumeration. I tried using this type syntax: value = <%# ((int)MyEnum.Value).ToString() %>" I get an error list item does not support databinding. Any ideas? ...

What is the best way to collapse an optional Grid Column at runtime?

Currently I have a Grid with 6 optional fields, one on each row, in a data template bound to my view model. 6 Rows - 2 Columns Column 0 has the label Column 1 has the content associated with the label. In this case I want to collapse the column when the Column 0 label is null. My plan is to simply create a converter, if content is ...

Declarative / Imperative Cross Over

I'm looking for a way to gain reference to a class that was instanciated via XML, but I need reference to it in imperative code. I usually do this via the datacontext of the control, but in this case, the user control does not have declaritive reference to the class that I require. I know I have seen how to gain a reference to a class ...

Declarative syntax for a collection of value types in ASP.NET?

I know that in ASP.NET (talking about 2.0 here primarily) one can set a property on an object that takes a collection of things (an enumerable type I'm guessing is the trigger) and then reference it declaritivly. For example: <ObjectDataSource properties="blahblahblah"> <SelectParameters> <asp:Parameter /> </SelectParam...

Problem implementing declarative transactions

Hi I want to implement transaction control at the function level. What i want is something like this. class MyService{ static transactional = false @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public def saveCountry(){ Country co = new Country(name:'mycountry') co.save() createState...

ADT properties in Mercury

I wander why Mercury (10.04) can't infer determinism of next snippet: :- pred load_freqs(int::in, io.res(list(float))::out, io::di, io::uo) is det. load_freqs(CPU, ResFreqs, !IO):- open_input(cpu_fn(CPU, "available_frequencies"), ResStream, !IO), (ResStream = io.ok(Stream) -> ResFreqs = io.ok([]) ;ResStream = io.erro...

SQLAlchemy introspection of declarative classes

I'm writing a small sqlalchemy shim to export data from a MySQL database with some lightweight data transformations—mostly changing field names. My current script works fine but requires me to essentially describe my model twice—once in the class declaration and once as a list of field names to iterate over. I'm trying to figure out ...

problem assigning declarative values in asp:hyperlink. error: this is not scriptlet. will output as plain text.

Hi. I am trying to do this: <asp:HyperLink NavigateUrl='<%= WebContext.RootUrl %><%= WebContext.CurrentUser.UserName %>' runat="server" Text='<%= GetProfileImage(WebContext.CurrentUser.AccountId) %>'></asp:HyperLink> But am getting the error: this is not scriptlet. will output as plain text. when I mouse over my declarativ...

Is there a declarative way to parse XML to Java objects?

I'm writing an import function of XML files to my Java application. I am using XOM to parse the XML files. The code for parsing the XML is not easy to understand, it is some hardcoded .getChild(3) and so on. It is hard to follow the code compared to the declarative XML document. Isn't there a more maintainable way to parse XML documents...

What are the advantages of attribute based programming ?

Hi, I am working with WCF RIA services and have come across a sample using attributes: [StringLength(10, ErrorMessage="Too long")] public string FirstName { get; set; } ... While attributes aren't restricted to WCF RIA, it reminded me of a question: why is declarative or attribute based programming perferable to coding a validation r...

sqlalchemy: turn off declarative polymorphic join?

Is there a way in sqlalchemy to turn off declarative's polymorphic join loading, in a single query? Most of the time it's nice, but I have: class A(Base) : discriminator = Column('type', mysql.INTEGER(1), index=True, nullable=False) __mapper_args__ = { 'polymorphic_on' : discriminator } id = Column(Integer, primary_key=True) ...

SQLAlchemy context sesitive function for creating a composite value on insert and update

I'm trying to sort out how to add a context sensitive function (e.g. def get_user_full_name()) that will get triggered from the default and onupdate specifications on a column. I'm trying to set a composite field that combines the first and last names into a single full name value to avoid having to constantly concat the two fields in a...

Is it a Bad idea to use `<%=` in a WebControl

Recently I've started using <%= more often in my Web Controls. Typically I'll set String properties in the Code Behind and then spit them out onto the form. Is this a bad idea? eg. Code Behind: Properties: public string TheTitle { get; set; } public string TheBody { get; set; } public ContentItem TheContent { get; set; } public st...