I am using pyamf with google app engine. I am trying to exclude a property from the pyamf encoding. This is the syntax I am using:
class Comment(db.Model):
class __amf__:
exclude = ('article')
article = db.ReferenceProperty(Article)
comment = db.TextProperty()
This does not work on the ReferenceProperty but if I try the exclude property with the 'comment' attribute it works. I noticed that the exclude property worked on a ReferenceProperty that did not contain a class with another ReferenceProperty attribute. In this case the Article class holds another ReferenceProperty to a another class. Any idea what could be the problem?
Thanks in advance
Your problem seems to be, at least partly, one of syntax -- you want the following:
exclude = ('article',)
Single parentheses without commas in them are just parenthesized expressions; they are evaluated earlier but do not mean "this is a tuple literal" -- that requires a colon.
Related
this might be a very very basic question, but what is the best way to name my forms?
I mean, can I use spaces or will that give me problems later on?
Example
Should I use "Logged on Popup" or "Logged_on_Popup"?
Thanks!
Don't use spaces. Or Underscores. Microsoft do have some naming conventions that they recommend. Whilst they don't specifically have any recommendations re: form naming, they may be quite a good read:
Do favor readability over brevity. The property name CanScrollHorizontally is better than ScrollableX (an obscure reference to the X-axis).
Do not use underscores, hyphens, or any other nonalphanumeric characters.
Also, bear in mind that the name used in your code isn't exposed to the end users - whereas the captions of your forms are - make sure that those captions are well chosen.
Since Forms are also classes, you should follow the Class Namings:
Use a noun or noun phrase to name a class.
Use Pascal case.
Use abbreviations sparingly.
Do not use a type prefix, such as C for class, on a class name. For example, use the class name FileStream rather than CFileStream.
Do not use the underscore character (_).
Occasionally, it is necessary to provide a class name that begins with the letter I, even though the class is not an interface. This is appropriate as long as I is the first letter of an entire word that is a part of the class name. For example, the class name IdentityStore is appropriate.
Where appropriate, use a compound word to name a derived class. The second part of the derived class's name should be the name of the base class. For example, ApplicationException is an appropriate name for a class derived from a class named Exception, because ApplicationException is a kind of Exception. Use reasonable judgment in applying this rule. For example, Button is an appropriate name for a class derived from Control. Although a button is a kind of control, making Control a part of the class name would lengthen the name unnecessarily.
So Log On Popup is invalid and Log_On_Popup should be valid from a compiler perspective, but not from the class naming guidelines. I should opt for LogOnPopup. Where some people like to add a suffix to it LogOnPopupForm.
public partial class LoggedOnPopupForm
In component name you can use spaces but I don't recommend doing it
Simple,
You can use log_on_popup
If your doubt is how to name it then, When your Form designer is open, open the properties window (If properties window is not there, just right click on the form and select properties), In properties , You will find (Name) just type there log_on_popup :)
Using bulkloader in App Engine, I can get properties set to certain values or to None (or null value). I can also leave them unset if I don't include the property in bulkloader.yaml.
What I would like to do is set the property for some of the entities and leave the property unset for some other entities. Is there a way to do this?
There's no way to do this with the standard YAML configuration of the bulkloader. Note, though, that most model frameworks, including the Python one built in to App Engine, will create any missing properties when you first write a record with them, so there's not much point in going out of your way to leave them unspecified.
You can do this with a post_import_function.
Let's say you have a string property called "notes" that should be omitted if empty:
def post_process_entity(input_dict, instance, bulkload_state):
if instance['notes'] == '':
del instance['notes']
return instance
in a XAML file (a WPF UserControl), is there a way to reference an inner class "B" defined in another class "A" ?
public class A
{
public class B
{
}
}
Something like :
<local:A.B ... />
This syntax does not work because "B" is interpreted as a property named "B" in class "A".
I've tried more exotic syntaxes like "::" or "+" but none seems to work.
I'm currently using Silverlight 4 with VS2010.
Thanks in advance for your help.
This question is pretty old, and I don't know if it would have worked with the version of WPF back in 2010, but now you can make it work by using the "real" (internal) name of the nested type:
<local:A+B />
If you've ever looked a disassembled code, that's how nested types look like:
ParentTypeName+Nested
I was searching and searching, because if this is possible, I would like to know. Unfortunately, I found this on msdn:
Your custom class must not be a nested
class. Nested classes and the "dot"
in their general CLR usage syntax interfere with other WPF and/or XAML
features such as attached properties.
So, it appears you can't reference a nested class with the dot operator. As for alternative ways of getting to that inner class through XAML, I haven't had any luck in my searches yet. :o( But this is a rather interesting issue, so I will continue searching. Maybe I'll find some luck! :o)
. refers to a property; not sure why XAML couldn't also search for a nested class, but it doesn't.
A nested class can be represented when inside a string (e.g. a property value), using A+B instead of A.B:
<Label SomeProperty1="{x:Static local:A+B.SomeProperty2}" />
As an element name (as shown in question), + is not allowed, as the result would no longer be valid XML; + is not a valid name character:
XAML is XML.
XML Spec - NameChar.
So the element name cannot directly describe a nested class.
BUT see UPDATE below - an alternative syntax that solves this.
UPDATE
Per #Artfunkel's comment on one answer, this should be a solution [I have not tested]:
<x:Type TypeName="local:A+B"/>
From: https://learn.microsoft.com/en-us/dotnet/framework/xaml-services/x-type-markup-extension
TBD how to specify property name with that syntax. Use x:TypeArguments?
in cakebook on page http://book.cakephp.org/view/1331/Defining-the-Fields there is a sentence what I am not able interpret:
When defining fields for TranslateBehavior to translate, be sure to omit those fields from the translated model's schema. If you leave the fields in, there can be issues when retrieving data with fallback locales.
Can somebody explain me in a more simple way than it is in originally?
I think I have language problem as english is not my native :P
It means that in the following case:
class Article extends AppModel
{
var $actsAs = array('Translate' => array('title'));
}
You should not have the field Article.title (i.e. articles.title) in your database, otherwise you'll have trouble at some point.
Basically, when you design your table you plan to translate, omit those fields you want to translate.
Hope that helps!
I've never used that behaviour and I have to say that I would be looking elsewhere for an explanation of how to use it as I too (and I'm English) am having trouble understanding it.
My guess is that you need to ensure that there are no fields in the i18n table with the same name as a field that you are translating, i.e. if you are translating Post.name you must be careful not to have i18nTable.name
I don't use the console and there is no explanation of the required name or structure of the i18n table, so my comment is guesswork but I hope that it is in someway helpful.
In a ClearCase config spec, is it possible to select versions based on element attributres (not version attributes)? For instance:
element * ...{SOME_ELEM_ATTR==SOME_VALUE&&lbtype(MY_LABEL1)}
This doesn't work because the last part of the "element" spec is a version-selector, which only looks at version attributes.
What I'm trying to do is partition my files into two or more classes, and have different "element" lines apply to different classes of files. I tried tagging all the elements in one class with an attribute, but hit a dead end with trying to base the selection on that in the config spec. The only way I can see to do this sort of thing is to put all the files of one class in one place and use the second construct (the "pattern") to differentiate:
element .../all_class1_files/... MY_LABEL1
but this is really ugly because you have to move all the files of one class into one place, or have a giantic config spec listing all the individual directories and/or files.
Thanks in advance...
Ray
One first solution would be to replace the attribute criteria by a branch.
That way, you would more easily be able to label all files from one branch or another, instead of "all files with a given attribute".
Other than this workaround, you will find some find command based on attribute here (or in the man page).
You could then combine a find query with an "-exec" directive to put the label that you want.
That way, you don't have to mess with the config spec syntax (which may not support the exact selection criteria you are after).
I didn't test it, but you could try
element * ...{SOME_ELEM_ATTR==SOME_VALUE && lbtype_sub(MY_LABEL1)}
, because lbtype_sub is an element, branch and version selector (whereas lbtype is just a version selector).
However, since lbtype doesn't seem to be part of the config spec criteria, I doubt it can work in said config spec.
I think I've up with a good solution using "trtype" as a selection criterion (appears to be the only query function that inherits from the element to the version). If the Class1 and Class2 elements have dummy triggers Class1Files andClass2Files attached to them, respectively, then something like
element * .../{trtype(Class1Files)&&lbtype(MY_LABEL1)}
element * .../{trtype(Class2Files)&&lbtype(MY_LABEL2)}
should do the trick. This selects files in Class1 with MY_LABEL1 and in Class2 with MY_LABEL2. I haven't actually tried this out yet, but I'll let you know how this works out.