Creating a file that contains the set of inputs in pyqt - pyqt4

I have created a widget with a text bix, a combo box, a checkbox and some pushbottons. I wish to make a record of the set of input given everytime in a file. how do I do that ? Pls suggest.

The easiest and not that bad way imho is by reading the values and serializing them using json. You have to set/get the values individually for each input (with different calls). It's a breeze in fact. Personally, I have made my own 'serializing' function so I keep references to all objects in a list and that function loops the list serializing everything.
Depending on your needs and the complexity of your project you may need something different. Why don't you share some more details?
Best Regards.

Related

an alternative for getAllEntriesByKey?

I want to build a type-ahead function but I need an alternative to getAllEntriesByKey method because the initial data collection is seems to be too large for an acceptable performance.
I would rather like to use the getEntryByKey method and the next X number of documents in a View.
Is something possible? Just jump into a position in a view (matching a specified query) and collect the next X number of documents?
For now I have written most in SSJS.
you can use a combination of NotesView.GetEntryByKey and NotesView.CreateViewNavFrom. This means however you will access the view twice so I do not know if you gain any performance improvement here.
An example (LotusScript) can be found here:
http://lpar.ath0.com/2011/09/19/notesviewentrycollection-vs-notesviewnavigator/
The LotusScript can easily be transformed into SSJS. I have used it something similar before. I can write a blog-post about it.

Is it possible to have multiple data sources in coded ui test

I'm trying to set up a Coded UI test and have the desire to pull values from two separate data sources (in this case xml files). I have been doing this with just one data source many times but have a couple questions concerning multiple sources.
Is it possible to have two data sources for the same Coded UI test?
If so, how do you differentiate between them when reading values -
when using just one data source I use the
'this.TestContext.DataRow["blah"].toString();' method.
Thanks in advance for any help
erik
Finally found something (not sure how I missed it the first time) which indicates there can be only one TestMethod attribute per Test method (duh to me). So, I guess my refined question is; is there a way around that limitation? This is a long shot I know but would simplify things. Thanks again.
It is not possible to have more than one Data Source for Single Test, But if your test needs data to be read from two different sources then you can write your custom code to read values from external source in between the test.
i.e. You can have one Data source which controls the iteration of test and other one in your custom code to get value for each iteration of test.
We have tests here which read multiple data sources. You can put the connections to the data sources in a separate class (you can put them in the same function, just call the function once to open them) then reference the data sources from wherever you need them.
As for the [Test Method] issue, the same applies. You can place [Test Method] in the second class before the function with the data sources.

bind textbox with core framework

i already searched for an answer but without finding one to my specific problem.
i am using core data to save profiles and display them in a table. since core data is already set up, i wanted to use it also for storing application settings.
i've set up the model, set up an array controller to retrive the data, but now, i have no clue on how to connect this array controller to a single textbox.
i try to explain: theoretically my model could have more entries, just like the profile model has. but it has just one with some settings, as if a database would have only a single data row. is there a way i can specify that i want the data contained in the very first row? dont know if my question is clear, its not so easy to explain. please if it was not clear let me knwo and i will try to explain it again.
thanks
igor
Don't put application settings in Core Data. Any time you find yourself thinking that you want just one instance (row) for an entity, you're doing it wrong.
Cocoa Touch provides a class called NSUserDefaults specifically for the purpose of saving app settings. Look into that, it's almost certainly what you want.

How do I set default values of fields added to existing entities?

I'm adding 4 new checkboxes to an entity and its form. There are already instances of this entity created in production. I need to have these checkboxes defaulted to checked on these existing entity instances. I set the default value of the field but apparently this only gets used when a new instance of the entity is created. Is there an easy way to set these on all the existing instances?
I could use a one-off workflow, but I don't know how many instances of this entity there are and due to auditing requirements I can't access the production environment.
You could create execute some JavaScript on the load of the form. Of course, this wouldn't update all of the values in the database, but it would update it before a user is able to view it. Do you need all the values in the database defaulted, or will java script work?
Edit
Your best options are either an update multiple ( you can increase the number of records an advanced find returns to 250 records per page) and continue to update all records manually, or perform a batch update. See this related SO question.
There's another way, too. You could write a console application that connects to your server (not that hard if you've done it before and don't have to make it general). Then, you simply execute an update on the service fetching all the existing entities and updating them after the change is made.
As #Daryl says, there's probably a way to do that from the GUI too, but real programmers do it the hard way. :)
Of course I'm kidding. I just love to type code, hehe. Never the less - once you start coding, you have full freedom to affect the data any way you need, forever.
You can do this by exporting the records and change the value for the field and then re-import back it.

Alternative Data Access pattern to Repository

I have certain objects in my domain which are not aggregate roots/entities, yet I still need to retrieve them from a database. I don't want to confuse things by creating repositories for these things. So, what are alternative data access patterns? Would you simply create a DAO for them, while still of course separating the interface?
Edit:
Some more detail on what I'm doing. I need to create a code. This code has certain rules as to its format. One of the rules is that the final character must be a unique number incremented by one from the last code generated. For example:
ABCD1
ABCD2
ABCD3
So, I'm keeping a table with one row, one column to store the number in question. Now, I don't want to consider this number an entity and create a repository for it - that's overkill. I just need a way of retrieving the number, adding 1 to it, and saving it. I know there are myriad ways I could do it, but I'm wondering if there's an customary way.
There are several data access patterns that could apply, in theory. You'd need to provide more detail though if you want us to suggest a specific pattern.
Without more detail, all I can suggest is to consider looking into Martin Fowler's Patterns of Enterprise Application Architecture book.
Edit: Customary way? No, not that I can think of - it really depends on where and how you're using this unique code in your domain. If I were doing this, I'd probably create a small service that speaks directly to the database to perform this function - not as heavy-weight as a repository, and very focused on the problem at hand.
Based on the edit: I would look first at the context in which you need to create that code. Perhaps there are some related entities or something that you are missing.
btw, I find the question really interesting as it comes up from time to time while coding specific features. I usually end up finding I was missing something on the scenario and it ends up fitting well with the normal repository pattern.
After surveying the options I'm going with the Table Gateway pattern.

Resources