Daily Archives

Articles indexed Wednesday December 29 2010

Page 18/33 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Inheritance Mapping Strategies with Entity Framework Code First CTP5: Part 2 – Table per Type (TPT)

    - by mortezam
    In the previous blog post you saw that there are three different approaches to representing an inheritance hierarchy and I explained Table per Hierarchy (TPH) as the default mapping strategy in EF Code First. We argued that the disadvantages of TPH may be too serious for our design since it results in denormalized schemas that can become a major burden in the long run. In today’s blog post we are going to learn about Table per Type (TPT) as another inheritance mapping strategy and we'll see that TPT doesn’t expose us to this problem. Table per Type (TPT)Table per Type is about representing inheritance relationships as relational foreign key associations. Every class/subclass that declares persistent properties—including abstract classes—has its own table. The table for subclasses contains columns only for each noninherited property (each property declared by the subclass itself) along with a primary key that is also a foreign key of the base class table. This approach is shown in the following figure: For example, if an instance of the CreditCard subclass is made persistent, the values of properties declared by the BillingDetail base class are persisted to a new row of the BillingDetails table. Only the values of properties declared by the subclass (i.e. CreditCard) are persisted to a new row of the CreditCards table. The two rows are linked together by their shared primary key value. Later, the subclass instance may be retrieved from the database by joining the subclass table with the base class table. TPT Advantages The primary advantage of this strategy is that the SQL schema is normalized. In addition, schema evolution is straightforward (modifying the base class or adding a new subclass is just a matter of modify/add one table). Integrity constraint definition are also straightforward (note how CardType in CreditCards table is now a non-nullable column). Another much more important advantage is the ability to handle polymorphic associations (a polymorphic association is an association to a base class, hence to all classes in the hierarchy with dynamic resolution of the concrete class at runtime). A polymorphic association to a particular subclass may be represented as a foreign key referencing the table of that particular subclass. Implement TPT in EF Code First We can create a TPT mapping simply by placing Table attribute on the subclasses to specify the mapped table name (Table attribute is a new data annotation and has been added to System.ComponentModel.DataAnnotations namespace in CTP5): public abstract class BillingDetail {     public int BillingDetailId { get; set; }     public string Owner { get; set; }     public string Number { get; set; } } [Table("BankAccounts")] public class BankAccount : BillingDetail {     public string BankName { get; set; }     public string Swift { get; set; } } [Table("CreditCards")] public class CreditCard : BillingDetail {     public int CardType { get; set; }     public string ExpiryMonth { get; set; }     public string ExpiryYear { get; set; } } public class InheritanceMappingContext : DbContext {     public DbSet<BillingDetail> BillingDetails { get; set; } } If you prefer fluent API, then you can create a TPT mapping by using ToTable() method: protected override void OnModelCreating(ModelBuilder modelBuilder) {     modelBuilder.Entity<BankAccount>().ToTable("BankAccounts");     modelBuilder.Entity<CreditCard>().ToTable("CreditCards"); } Generated SQL For QueriesLet’s take an example of a simple non-polymorphic query that returns a list of all the BankAccounts: var query = from b in context.BillingDetails.OfType<BankAccount>() select b; Executing this query (by invoking ToList() method) results in the following SQL statements being sent to the database (on the bottom, you can also see the result of executing the generated query in SQL Server Management Studio): Now, let’s take an example of a very simple polymorphic query that requests all the BillingDetails which includes both BankAccount and CreditCard types: projects some properties out of the base class BillingDetail, without querying for anything from any of the subclasses: var query = from b in context.BillingDetails             select new { b.BillingDetailId, b.Number, b.Owner }; -- var query = from b in context.BillingDetails select b; This LINQ query seems even more simple than the previous one but the resulting SQL query is not as simple as you might expect: -- As you can see, EF Code First relies on an INNER JOIN to detect the existence (or absence) of rows in the subclass tables CreditCards and BankAccounts so it can determine the concrete subclass for a particular row of the BillingDetails table. Also the SQL CASE statements that you see in the beginning of the query is just to ensure columns that are irrelevant for a particular row have NULL values in the returning flattened table. (e.g. BankName for a row that represents a CreditCard type) TPT ConsiderationsEven though this mapping strategy is deceptively simple, the experience shows that performance can be unacceptable for complex class hierarchies because queries always require a join across many tables. In addition, this mapping strategy is more difficult to implement by hand— even ad-hoc reporting is more complex. This is an important consideration if you plan to use handwritten SQL in your application (For ad hoc reporting, database views provide a way to offset the complexity of the TPT strategy. A view may be used to transform the table-per-type model into the much simpler table-per-hierarchy model.) SummaryIn this post we learned about Table per Type as the second inheritance mapping in our series. So far, the strategies we’ve discussed require extra consideration with regard to the SQL schema (e.g. in TPT, foreign keys are needed). This situation changes with the Table per Concrete Type (TPC) that we will discuss in the next post. References ADO.NET team blog Java Persistence with Hibernate book a { text-decoration: none; } a:visited { color: Blue; } .title { padding-bottom: 5px; font-family: Segoe UI; font-size: 11pt; font-weight: bold; padding-top: 15px; } .code, .typeName { font-family: consolas; } .typeName { color: #2b91af; } .padTop5 { padding-top: 5px; } .padTop10 { padding-top: 10px; } p.MsoNormal { margin-top: 0in; margin-right: 0in; margin-bottom: 10.0pt; margin-left: 0in; line-height: 115%; font-size: 11.0pt; font-family: "Calibri" , "sans-serif"; }

    Read the article

  • Reflecting on 2010 and Looking into 2011

    - by Sam Abraham
    In early 2010, I had blogged and shared my excitement as I was about to embark on a new journey relocating to South Florida.     As I settled down and adjusted to my new life, I was presented with an opportunity to get actively involved and volunteer in the local Florida .Net and Project Management communities.  I have since devoted a significant portion of my time to community initiatives, coordinating the West Palm Beach .Net User Group, volunteering as a member of the INETA Speaker’s Bureau and traveling to attend/speak at .Net code camps and user groups throughout the states of Florida and New York. I have also taken on various volunteer roles at the South Florida Chapter of the Project Management Institute starting as core team member on the chapter’s mentoring initiative and ending the year as Project Manager of the chapter’s mentoring program and as Director of Electronic Communications on the chapter’s IT team. I am also serving a one year term (2010-2011) as secretary and founding board member of Florida’s first official chapter of the International Association for Software Architects (IASA).   A big thank you is due for those who afforded me the opportunity and privilege to take part of these initiatives and those who provided guidance and encouragement when I needed them the most.   Looking ahead into 2011, I hope to continue my community involvement and volunteer activities. I will start by dedicating the first 5 weekends in the New Year to teach a free comprehensive Microsoft PowerPoint class at church. My goal will be to start from scratch and slowly cover the various available PowerPoint features that can be leveraged to create captivating presentations. Starting February, I will be resuming my user group/code camp speaking engagements at our South Florida .Net Code Camp and the West Palm Beach .Net User Group.   I look forward to continuing to meet, chat and share with our technical community members and to another active year in community service.   All the best, --Sam Abraham

    Read the article

  • Repeater vs. ListView

    - by MoezMousavi
    I do really hate repeater. I was more a GridView lover but after 3.5 be born, I prefer ListView.  The first problem with Repeater is paging. You will need to write code to handle paging. Second common problem is empty data template. Have a look at this:             if (rptMyRepeater.Items.Count < 1)             {                 if (e.Item.ItemType == ListItemType.Footer)                 {                     Label lblFooter = (Label)e.Item.FindControl("lblEmpty");                     lblFooter.Visible = true;                 }             }   I found the above code is usefull if you need to show something like "There is no record" is your data source has no records. Although the ListView has a template.   If you combine ListView with a DataPager, you will be in heaven as it is sorting the paging for you without writing code. (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.aspx)     Note: You have got to bind ListView in PreRender, it doesn't work properly in PageLoad   More: http://www.4guysfromrolla.com/articles/061009-1.aspx

    Read the article

  • DataContractSerializer: type is not serializable because it is not public?

    - by Michael B. McLaughlin
    I recently ran into an odd and annoying error when working with the DataContractSerializer class for a WP7 project. I thought I’d share it to save others who might encounter it the same annoyance I had. So I had an instance of  ObservableCollection<T> that I was trying to serialize (with T being a class I wrote for the project) and whenever it would hit the code to save it, it would give me: The data contract type 'ProjectName.MyMagicItemsClass' is not serializable because it is not public. Making the type public will fix this error. Alternatively, you can make it internal, and use the InternalsVisibleToAttribute attribute on your assembly in order to enable serialization of internal members - see documentation for more details. Be aware that doing so has certain security implications. This, of course, was malarkey. I was trying to write an instance of MyAwesomeClass that looked like this: [DataContract] public class MyAwesomeClass { [DataMember] public ObservableCollection<MyMagicItemsClass> GreatItems { get; set; }   [DataMember] public ObservableCollection<MyMagicItemsClass> SuperbItems { get; set; }     public MyAwesomeClass { GreatItems = new ObservableCollection<MyMagicItemsClass>(); SuperbItems = new ObservableCollection<MyMagicItemsClass>(); } }   That’s all well and fine. And MyMagicItemsClass was also public with a parameterless public constructor. It too had DataContractAttribute applied to it and it had DataMemberAttribute applied to all the properties and fields I wanted to serialize. Everything should be cool, but it’s not because I keep getting that “not public” exception. I could tell you about all the things I tried (generating a List<T> on the fly to make sure it wasn’t ObservableCollection<T>, trying to serialize the the Collections directly, moving it all to a separate library project, etc.), but I want to keep this short. In the end, I remembered my the “Debug->Exceptions…” VS menu option that brings up the list of exception-related circumstances under which the Visual Studio debugger will break. I checked the “Thrown” checkbox for “Common Language Runtime Exceptions”, started the project under the debugger, and voilà: the true problem revealed itself. Some of my properties had fairly elaborate setters whose logic I wanted to ignore. So for some of them, I applied an IgnoreDataMember attribute to them and applied the DataMember attribute to the underlying fields instead. All of which, in line with good programming practices, were private. Well, it just so happens that WP7 apps run in a “partial trust” environment and outside of “full trust”-land, DataContractSerializer refuses to serialize or deserialize non-public members. Of course that exception was swallowed up internally by .NET so all I ever saw was that bizarre message about things that I knew for certain were public being “not public”. I changed all the private fields I was serializing to public and everything worked just fine. In hindsight it all makes perfect sense. The serializer uses reflection to build up its graph of the object in order to write it out. In partial trust, you don’t want people using reflection to get at non-public members of an object since there are potential security problems with allowing that (you could break out of the sandbox pretty quickly by reflecting and calling the appropriate methods and cause some havoc by reflecting and setting the appropriate fields in certain circumstances. The fact that you cannot reflect your own assembly seems a bit heavy-handed, but then again I’m not a compiler writer or a framework designer and I have no idea what sorts of difficulties would go into allowing that from a compilation standpoint or what sorts of security problems allowing that could present (if any). So, lesson learned. If you get an incomprehensible exception message, turn on break on all thrown exceptions and try running it again (it might take a couple of tries, depending) and see what pops out. Chances are you’ll find the buried exception that actually explains what was going on. And if you’re getting a weird exception when trying to use DataContractSerializer complaining about public types not being public, chances are you’re trying to serialize a private or protected field/property.

    Read the article

  • cannot unset env variables from script

    - by w00t
    Hi, I am trying to unset all environment variables from within a script. The script runs fine but if I run env it still shows all the variables set. If I run the command from CLI, it works and the variables are unset. unset `env | awk -F= '/^\w/ {print $1}' | xargs` Have any idea how to run this from a script? Also, have any idea how to source /etc/profile from a script? This doesn't work either. I need to set variables with same names but different paths, depending on the instances my users need.

    Read the article

  • php include path problem:Same code works on Ubuntu default Apache and php conf, but not on CentOS

    - by Neo
    So the same code works on my ubuntu server but when I upload it to my dedicated hosting server running CentOS it seems to add an extra prefix of .:/usr/share/pear:/usr/share/php: I tried setting includepath to different things but it just doesn't work. the file is in a directory called language in the same folder as the file that is including it and I'm using : include dirname(FILE).DIRECTORY_SEPARATOR."language".DIRECTORY_SEPARATOR."storage.inc"; and include dirname(__FILE__)."/language/language.php"; and include "language/language.php"; and alot of other combinations but I can't get it to find the file. Fatal error: require_once() [function.require]: Failed opening required '/home/neo/public_html/migration/include/class/core/storage.inc' (include_path='.:/usr/share/pear:/usr/share/php:/home/neo/public_html/migration') in /home/neo/public_html/migration/include/class/core/class_lang.inc on line 153

    Read the article

  • Problem while Installing mysql cluster

    - by Champion
    I downloaded latest mysql cluster file 64 bit (mysql-cluster-gpl-7.1.9-linux-x86_64-glibc23) from mysql site. Ran following command to install mysql server. /home/mysql_cluster/mysqlc/scripts/mysql_install_db --no-defaults --basedir=/home/mysql_cluster/mysqlc --datadir=/home/mysql_cluster/my_cluster/mysqld_data It's giving following issues. /home/mysql_cluster/mysqlc/scripts/mysql_install_db: line 245: /home/mysql_cluster/mysqlc/bin/my_print_defaults: No such file or directory Neither host 'db' nor 'localhost' could be looked up with /home/mysql_cluster/mysqlc/bin/resolveip Please configure the 'hostname' command to return a correct hostname. If you want to solve this at a later stage, restart this script with the --force option My host is pinging and hostname command gives correct hostname. I tried also with --force option force but still not working giving following issues: /home/mysql_cluster/mysqlc/scripts/mysql_install_db: line 245: /home/mysql_cluster/mysqlc/bin/my_print_defaults: No such file or directory Installing MySQL system tables... /home/mysql_cluster/mysqlc/scripts/mysql_install_db: line 393: /home/mysql_cluster/mysqlc/bin/mysqld: No such file or directory Installation of system tables failed! Examine the logs in /home/mysql_cluster/my_cluster/mysqld_data for more information. It says above files doesn't exist but this files are present checked with ls command. We are using XEN VM with 64 bit debian lenny os. How this issue can be resolved ?

    Read the article

  • AIX 5.3 Package Dependency

    - by user60899
    Hi All, I want to install gettext but i cannot because my AIX says that gettext is dependent on glib and when i try to install glib it says that I cannot because glib is in turn dependent on gettext. Please let me know how I could get past this situation? root [rover]% rpm -i gettext-0.17-1.aix5.1.ppc.rpm error: failed dependencies: libglib-2.0.a(libglib-2.0.so.0) is needed by gettext-0.17-1 libxlsmp.a(smprt.o) is needed by gettext-0.17-1 root [rover]% rpm -i glib2-2.22.5-2.aix5.1.ppc.rpm error: failed dependencies: gettext is needed by glib2-2.22.5-2 Regards, Anurag

    Read the article

  • How do I split a large MySql backup file into multiple files?

    - by Brian T Hannan
    I have a 250 MB backup SQL file but the limit on the new hosting is only 100 MB ... Is there a program that let's you split an SQL file into multiple SQL files? It seems like people are answering the wrong question ... so I will clarify more: I ONLY have the 250 MB file and only have the new hosting using phpMyAdmin which currently has no data in the database. I need to take the 250 MB file and upload it to the new host but there is a 100 MB SQL backup file upload size limit. I simply need to take one file that is too large and split it out into multiple files each containing only full valid SQL statements (no statements can be split between two files).

    Read the article

  • Contacts and chat history of skype was lost.

    - by oommu
    First, my skype didn't have sound effects so I uninstalled it then I reinstall the skype. The sound effect still not working so I downloaded the new version of skype ( beta one), I installed it then the sound effect still not working so I download the old version of skype then install it. The sound effect works but I lost all of my contacts and lost all of chat history. The chat history is really important for me. May you please help me to restore my chat history? Thank you.

    Read the article

  • netbook intel GMA 3150 external monitor 1920x1080 flicker problem

    - by seyenne
    Dear all, i recently purchased a acer netbook (apsire one d260). It runs flawlessly. Yesterday I bought a samsung 23" TFT with a native resolution of 1920x1080. According to the information found in the internet and my local computer dealer, the intel chipset can handle the native resolution of the monitor. However, this is only partly the case. I use the VGA cabel to connect, the monitor instantly switches to the native resolution and now the problem: Occasionaly, especially the first 2 hours after booting up, I have a flickering all over the screen, sometimes the entire screen is shaking and spinning around like crazy. I figured out, that lowering the resolution avoids the flicker but this helps only for some time. I can rule out that it's the monitor's problem since I found no issues with another notebook. Right now, I have no problems with the netbook, for about 30 minutes I didn't experience any issues... But I don't know for how long, it occurs without warning :-) I'm worried that if I would bring the netbook back to the dealer and explain my problem, after testing it on an external screen in the local shop, everything works just fine... And I won't get helped with the problem because I can't prove it. (I'm currently in Thailand and over here, customer service is nothing like back home in Germany) What can I do? Is this a driver related issue? (I installed the latest GPU driver) Is it because of the VGA cable? (But why does it work sometimes without any problems and with no issues on the other notebook) I monitored the GPU/CPU temperature, nothing changes really over time..Can it simply be a faulty GPU and is a replacement justifiable? I'm really stressed now because for the time I'm writing, the flickering didn't occur...but for sure, soon or later it will happen again.. I Forgot to mention, the problem also happens if the netbook runs on battery, unplugged. So the only hardware that is plugged is the TFT screen. ...........and here it comes again, flickering has just begun. NEED HELP! Thank you all for reading through this and giving any suggestions if possible. Cheers

    Read the article

  • Ouverture de la rubrique Cloud Computing, pour trouver les ressources nécessaires à la compréhension et à l'utilisation du "Cloud"

    Bonjour à tous, La rubrique Cloud Computing vient de voir le jour à l'adresse http://cloud-computing.developpez.com. Cette rubrique contiendra des news et toutes les ressources nécessaires à la compréhension, à l'utilisation et au développement pour et avec le "Cloud" (de Windows Azure aux Google Apps en passant par Salesforce et les serveurs HPC). Si vous avez des idées de tutoriels, d'articles, de sources ou encore de Q/R pour de prochaines FAQ, n'hésitez pas à nous en faire part. Très cordialement, Gordon...

    Read the article

  • New Oracle EM Book: "Oracle Enterprise Manager Grid Control Advanced OEM Techniques for the Real World" - First to include EM11g

    - by cristobal.soto(at)oracle.com
    The first book written about Enterprise Manager that covers the new Enterprise Manager Grid Control 11g which was released in April 2010 can be ordered now at a significant discount from http://www.rampant-books.com/book_1001_advanced_techniques_oem_grid_control.htmAbout the Author: Porus HavewalaPorus is a Senior Manager (Database Management) in the Enterprise Technology Program Office of Oracle Corporation based in Singapore. He has published numerous articles on Grid Control and RMAN on OTN, and created the world's first blog dedicated to Grid Control. Porus frequently speaks about Enterprise Manager at industry conferences and has created and executed an innovative program of seminars and workshops.

    Read the article

  • Buy HTC HD7 Windows Phone 7 From Airtel In India @ Rs. 29990

    - by Gopinath
    Are you looking for HTC HD 7 Windows Phone 7 in India? Head over to Airtel showroom near you to grab one. Airtel in partnership with HTC is offering HD 7 Windows Phone 7 for Rs. 29990 and users will get 2 GB of data usage for 6 months at Rs. 300. Mr. Shireesh Joshi, CMO-Mobile Services of Bharti Airtel,  in a press conference says We are delighted with the opportunity to bring the eagerly-awaited HTC HD7 Smartphone in India. Combining the strength of the airtel brand and network with the innovation and design of HTC and the great user-interface of Windows Phone 7, we are happy to bring another first for our customers that will take mobile communications to a whole new level. The HD7 has a 4.3-inch display, kickstand to rest your phone on a table, 5MP autofocus camera that allows you to record 720p videos, 1GHz processor, 576MB of RAM and has 16GB of internal memory. Even though this is the official launch of HTC HD7 in India, this phone is available in the market for quite sometime at an approximate price of Rs. 27000/-. So it’s your call to decide whether buy it at HTC authorized retailers like Airtel for Rs.29K  or in the market for Rs 27K. HTC HD 7 Promo Video Thanks Fonearena This article titled,Buy HTC HD7 Windows Phone 7 From Airtel In India @ Rs. 29990, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

  • Web Developer or Software Engineer?

    - by Deepesh
    A question that I have been asking myself and really confused which path to take. So I need your guys help as to the pros and cons of these 2 professions in today's world. I love web applications development as the Web is the best thing to happen in this age and nearly everyone gets by on the World Wide Web. And also tend to keep learning about new technologies and about web services. On the other hand I like software engineering also for the desktop applications as I have had experience with development small scale softwares in VB.Net, Java, C++, etc. Which path has more scope and better future? Whats your view?

    Read the article

  • Microsoft OneNote alternative?

    - by YSN
    Hi folks! Is there any program for Linux that has about the same functionality and usability as Microsoft OneNote? At the moment I am checking out Basket (for KDE), that seems to point to the right direction, but still lacks much of the functionality of OneNote and is very buggy unfortunately. For those of you, who do not know OneNote and want to get an idea of what I am talking about, please see the following video: http://www.youtube.com/watch?v=xdi67tnx6nA Any alternative suggestions (including a combination of different tools or apps running in wine) are very much appreciated. Thanks, YSN

    Read the article

  • Should I choose 10.04 LTS or 10.10?

    - by torbengb
    I'm new to Ubuntu (and Linux) but I want to give it a go. I've spent a few evenings trying to get 10.10 to run but I think my nVidia 8400 GS is causing trouble; only recovery mode with failsafeX gets me to the desktop (low-res but seems to be fully functional otherwise). Given that the xx.04 vesions are long-term support, I'm wondering whether it would be smarter for me to use that. I don't need to be on the cutting edge - I prefer to have a system that just works, long-term. Later I hope to move my media center and wife's netbook over too. Question: Why should I (not?) choose the 10.04 LTS version over the newest 10.10 version?

    Read the article

  • Installing Solaris Studio 12.2?

    - by KronoS
    I'm having a dickens of a time installing Solaris Studio 12.2 on Ubuntu 10.04. I found this guide, however using the alien option isn't finding the correct files. I'm not exactly sure on the syntax of alien, its kinda alien to me. (sorry for the bad pun) Also, when I download the tar file, and extract it, there are errors everytime saying things like: "operation not permitted" cannot creat symlink to '../prod/bin/cc': Operation not permitted I've extracted with super user access, but to no avail. Any success from anyone else?

    Read the article

  • Unable to uninstall Wine apps

    - by CrunchyNeo
    I recently ran the iTunes 10 installer in Wine and everything seemed to go well. Then, when I tried to run it, it would constantly crash/and the appearance would be glitchy. After looking at the Wine website, it turns out that iTunes 10 has a 'garbage' rating of Wine compatability. Now I'm trying to remove/uninstall iTunes, QuickTime, and the other applications that come default with installing iTunes (such as Bonjour, etc.). However, when I run the 'uninstaller' that wine provides for the programs, it instead executes what appears to actually be the original installer! I've tried deleting all the configuration/data files in my Wine's file-system, but to no avail. Any help is greatly appreciated! Edit1: After re-running the uninstall process and then rebooting, the program (iTunes 10) still remained installed.

    Read the article

  • IIS Permissions or NTFS Permissions?

    - by Jason
    I currently have a Windows Server 2003 setup to serve multiple sites via IIS. One of our directories needs to allow access to only 1 specific AD Security Group. I know there are two ways to accomplish this. One is using IIS to add permissions and the other is to set permissions on the folder/directory itself. A script runs at night and populates the content so users only need read permissions to view it in a browser. My question is which one is preferred?

    Read the article

  • 3D Camera Problem

    - by Chris
    I allow the user to look around the scene by holding down the left mouse button and moving the mouse. The problem that I have is I can be facing one direction, I move the mouse up and the view tilts up, I move down and the view titles down. If I spin around 180 my left and right still works fine, but when I move the mouse up the view tilts down, and when I move the mouse down the view titles up. This is the code I am using, can anyone see what the problem with the logic is? var viewDir = g_math.subVector(target, g_eye); var rotatedViewDir = []; rotatedViewDir[0] = (Math.cos(g_mouseXDelta * g_rotationDelta) * viewDir[0]) - (Math.sin(g_mouseXDelta * g_rotationDelta) * viewDir[2]); rotatedViewDir[1] = viewDir[1]; rotatedViewDir[2] = (Math.cos(g_mouseXDelta * g_rotationDelta) * viewDir[2]) + (Math.sin(g_mouseXDelta * g_rotationDelta) * viewDir[0]); viewDir = rotatedViewDir; rotatedViewDir[0] = viewDir[0]; rotatedViewDir[1] = (Math.cos(g_mouseYDelta * g_rotationDelta * -1) * viewDir[1]) - (Math.sin(g_mouseYDelta * g_rotationDelta * -1) * viewDir[2]); rotatedViewDir[2] = (Math.cos(g_mouseYDelta * g_rotationDelta * -1) * viewDir[2]) + (Math.sin(g_mouseYDelta * g_rotationDelta * -1) * viewDir[1]); g_lookingDir = rotatedViewDir; var newtarget = g_math.addVector(rotatedViewDir, g_eye);

    Read the article

  • Why does this valid Tkinter code crash when mixed with a bit of PyWin32?

    - by Erlog
    So I'm making a very small program for personal use in tkinter, and I've run into a really strange wall. I'm mixing tkinter with the pywin32 bindings because I really hate everything to do with the syntax and naming conventions of pywin32, and it feels like tkinter gets more done with far less code. The strangeness is happening in the transition between the pywin32 clipboard watching and my program's reaction to it in tkinter. My window and all its controls are being handled in tkinter. The pywin32 bindings are doing clipboard watching and clipboard access when the clipboard changes. From what I've gathered about the way the clipboard watching pieces of pywin32 work, you can make it work with anything you want as long as you provide pywin32 with the hwnd value of your window. I'm doing that part, and it works when the program first starts. It just doesn't seem to work when the clipboard changes. When the program launches, it grabs the clipboard and puts it into the search box and edit box just fine. When the clipboard is modified, the event I want to fire off is firing off...except that event that totally worked before when the program launched is now causing a weird hang instead of doing what it's supposed to do. I can print the clipboard contents to stdout all I want if the clipboard changes, but not put that same data into a tkinter widget. It only hangs like that if it starts to interact with any of my tkinter widgets after being fired off by a clipboard change notification. It feels like there's some pywin32 etiquette I've missed in adapting the clipboard-watching sample code I was using over to my tkinter-using program. Tkinter apparently doesn't like to produce stack traces or error messages, and I can't really even begin to know what to look for trying to debug it with pdb. Here's the code: #coding: utf-8 #Clipboard watching cribbed from ## {{{ http://code.activestate.com/recipes/355593/ (r1) import pdb from Tkinter import * import win32clipboard import win32api import win32gui import win32con import win32clipboard def force_unicode(object, encoding="utf-8"): if isinstance(object, basestring) and not isinstance(object, unicode): object = unicode(object, encoding) return object class Application(Frame): def __init__(self, master=None): self.master = master Frame.__init__(self, master) self.pack() self.createWidgets() self.hwnd = self.winfo_id() self.nextWnd = None self.first = True self.oldWndProc = win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, self.MyWndProc) try: self.nextWnd = win32clipboard.SetClipboardViewer(self.hwnd) except win32api.error: if win32api.GetLastError () == 0: # information that there is no other window in chain pass else: raise self.update_search_box() self.word_search() def word_search(self): #pdb.set_trace() term = self.searchbox.get() self.resultsbox.insert(END, term) def update_search_box(self): clipboardtext = "" if win32clipboard.IsClipboardFormatAvailable(win32clipboard.CF_TEXT): win32clipboard.OpenClipboard() clipboardtext = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() if clipboardtext != "": self.searchbox.delete(0,END) clipboardtext = force_unicode(clipboardtext) self.searchbox.insert(0, clipboardtext) def createWidgets(self): self.button = Button(self) self.button["text"] = "Search" self.button["command"] = self.word_search self.searchbox = Entry(self) self.resultsbox = Text(self) #Pack everything down here for "easy" layout changes later self.searchbox.pack() self.button.pack() self.resultsbox.pack() def MyWndProc (self, hWnd, msg, wParam, lParam): if msg == win32con.WM_CHANGECBCHAIN: self.OnChangeCBChain(msg, wParam, lParam) elif msg == win32con.WM_DRAWCLIPBOARD: self.OnDrawClipboard(msg, wParam, lParam) # Restore the old WndProc. Notice the use of win32api # instead of win32gui here. This is to avoid an error due to # not passing a callable object. if msg == win32con.WM_DESTROY: if self.nextWnd: win32clipboard.ChangeClipboardChain (self.hwnd, self.nextWnd) else: win32clipboard.ChangeClipboardChain (self.hwnd, 0) win32api.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, self.oldWndProc) # Pass all messages (in this case, yours may be different) on # to the original WndProc return win32gui.CallWindowProc(self.oldWndProc, hWnd, msg, wParam, lParam) def OnChangeCBChain (self, msg, wParam, lParam): if self.nextWnd == wParam: # repair the chain self.nextWnd = lParam if self.nextWnd: # pass the message to the next window in chain win32api.SendMessage (self.nextWnd, msg, wParam, lParam) def OnDrawClipboard (self, msg, wParam, lParam): if self.first: self.first = False else: #print "changed" self.word_search() #self.word_search() if self.nextWnd: # pass the message to the next window in chain win32api.SendMessage(self.nextWnd, msg, wParam, lParam) if __name__ == "__main__": root = Tk() app = Application(master=root) app.mainloop() root.destroy()

    Read the article

  • Dot Net Nuke module works in "Edit" mode but not for "View": cache problem?

    - by Godeke
    I have a DNN task that simply runs some Javascript to compute a price based on a few input fields. This module works fine on our production site, but we had a company do a skin for us to improve the look of the site and the module fails under this new system. (DNN 05.06.00 (459) although it was 5.5 prior... I updated in a futile hope that it was a bug in the old revision.) What is incredibly odd about this is that the module works fine when I'm logged in to DNN and using the Edit mode as an administrator. In this case the small snippet of JavaScript loads fine and filling the fields results in a price. On the other hand it I click "View" (or more importantly, if I'm not logged in at all) the page loads a cached copy. Even odder, I have found the cache files in \Portals\2\Cache\Pages are generated and then only the cached data is being used. When the cached copy is loaded, the JavaScript doesn't appear (it is normally created via a Page.ClientScript.RegisterClientScriptBlock(). Additionally, the button which posts the data to the server doesn't execute any of the server side code (confirmed with a debugger) but instead just reloads the cached copy. If I manually delete the files in \Portals\2\Cache\Pages then everything works properly, but I have to do so after every page load: failing to do so simply loads the page as it was last generated repeatedly. Resetting the application (either via the UI or editing web.config) doesn't change this and clearing the cache from the Host Settings page doesn't actually clear these cached pages. I'm guessing that Edit mode bypasses the cache in some way, but I have gone as far as turning off all caching on the site (which is horrible for performance) and the cached version is still loaded. Has anyone seen anything like this? Shouldn't clearing the cache clear the files (I'm using the File provider for caching)? Shouldn't even a cached page go back to the server if the user posts back? EDIT: I should point out that permissions don't appear to be a problem on the cache directory... other pages cached output are deleted from this folder, just this page has this issue. EDIT 2: Clarifying some settings and conditions which I didn't provide. First, this module works fine in production under DNN 5.6.0. In our test environment with the consulting company's changes it fails (the changes are skin and page layout only in theory: the module source itself verifies as unchanged). All cache settings and the like have been verified the same between the two and we only resorted to setting the module cache to 0 and -1 (and disabling the test site's cache entirely) when we couldn't find another cause for the problem. I have watched the cache work correctly on many other pages in test: there is something about this page that is causing the problem. We have punted and are creating an installable skin based on the consultant's work as I suspect they have somehow corrupted the DNN install (database side I think).

    Read the article

  • Storing database settings outside app.config

    - by Piers
    I've been writing a c# exe that will be running on a live web server, but I want to be able to test it on our staging server. Since the staging server has different database settings (in the app.config) from my localhost, is there any way I can store the connection string outside the app.config so that I can easily get to it? Also, is it possible to store the database connection string, then access it via the app.config? This might sound odd, but I'm using a dll from a CMS that uses the value in the .config file.

    Read the article

  • Rails forms: render different actions based on validation

    - by Martin Petrov
    Is it possible to render different actions based on what fails at validation? For example - I have one field in the form - email addres. It is validated like this: validates :email, :presence => true, :uniqueness => { :case_sensitive => false } In the controller: def create @user = User.new(params[:user]) if @user.save redirect_to somewhere else # render :new if email is blank # redirect_to somwhere if email is taken end end

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >